home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / bas_int1.zip / SHELL.BAS < prev    next >
BASIC Source File  |  1991-02-02  |  3KB  |  79 lines

  1. '=====================================================================  
  2. 'Sample program to demonstrate DoShell SUBroutine, which uses
  3. 'CALL Interrupt from QB.LIB (QB.QLB).
  4. '=====================================================================   
  5.      DEFINT A-Z
  6.      
  7.      TYPE RegType2
  8.           AX    AS INTEGER
  9.           BX    AS INTEGER
  10.           CX    AS INTEGER
  11.           DX    AS INTEGER
  12.           BP    AS INTEGER
  13.           SI    AS INTEGER
  14.           DI    AS INTEGER
  15.           Flags AS INTEGER
  16.           DS AS INTEGER
  17.           ES AS INTEGER
  18.      END TYPE
  19.      
  20.      'You must link with QB.LIB (QB.QLB) to use Interrupt functions
  21.      
  22.      DECLARE SUB InterruptX (Intr%, InReg AS RegType2, OutReg AS RegType2)
  23.      DECLARE SUB DoShell (Before$, Args$, After$)
  24.      
  25.      DoShell "Type EXIT to return", "", "Welcome back"   'Just to test it
  26.      END
  27.  
  28. '=====================================================================
  29. 'SUB DoShell(Before$,Args$,After$)
  30. 'Purpose: Use this routine rather than 'SHELL' and the original
  31. '         drive & directory will be restored when 'EXIT'ing the shell.
  32. '         Before$ = A reminder message to the user.  Usually it will be
  33. '                   something like "Type EXIT to return"
  34. '         After$ = A string message to the user upon reentry into the
  35. '                   calling program.
  36. '         Args$ = Will be the null string "" for a plain vanilla SHELL.
  37. '                 The SUB calls 'SHELL' as 'SHELL Args$'
  38. '======================================================================
  39.      SUB DoShell (Before$, Args$, After$) 'Declare some stuff to use
  40.      
  41.      DIM InReg AS RegType2
  42.      DIM OutReg AS RegType2
  43.      DIM CurrentDrive AS INTEGER
  44.      DIM CurrentDir AS STRING * 64
  45.      
  46.      'Get current disk drive
  47.      
  48.      InReg.AX = &H19 * 256
  49.      InterruptX &H21, InReg, OutReg
  50.      CurrentDrive = OutReg.AX MOD 256
  51.      
  52.      'Get current directory
  53.      
  54.      InReg.AX = &H47 * 256
  55.      InReg.DX = CurrentDrive + 1  'Note adding one to drive for this, or
  56.                                   'could use 0 for default drive
  57.      InReg.DS = VARSEG(CurrentDir)
  58.      InReg.SI = VARPTR(CurrentDir)
  59.      InterruptX &H21, InReg, OutReg
  60.      
  61.      'Do the shell
  62.      IF Before$ <> "" THEN CLS : PRINT Before$  'Optional
  63.      SHELL Args$
  64.      IF After$ <> "" THEN CLS : PRINT After$    'Optional
  65.      
  66.      'Change to old disk drive
  67.      InReg.AX = &HE * 256
  68.      InReg.DX = CurrentDrive
  69.      InterruptX &H21, InReg, OutReg
  70.           '(InReg.AX MOD 256 is the # of logical drives in the
  71.           'system if anyone is interested)
  72.      
  73.      'Change to old subdirectory (Could use Int &H21 func &H3B instead)
  74.      ToDir$ = CHR$(ASC("A") + CurrentDrive) + ":\" + LEFT$(CurrentDir, INSTR(CurrentDir, CHR$(0)))
  75.      CHDIR ToDir$
  76.      
  77.      END SUB
  78.  
  79.